package com.youme.section.shop.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.hyphenate.easeim.R
import com.youme.model.FoodAdd

class RecyclerAdapter(private val textList: List<FoodAdd>, val context: Context) :
    RecyclerView.Adapter<RecyclerAdapter.MyViewHolder>() {

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): MyViewHolder {
        val view =
            LayoutInflater.from(parent.context).inflate(R.layout.item_shop_details_food_right, parent, false)
        return MyViewHolder(view)
    }

    override fun getItemCount(): Int = textList.size ?: 0

    override fun onBindViewHolder(holder: RecyclerAdapter.MyViewHolder, position: Int) {
        val textpos = textList[position]
        holder.name.text = textpos.productName
        holder.price.text = "" + textpos.productPrice
        holder.num.text = "" + textpos.productQuantity
//        holder.juli.text = textpos.juli
//        holder.prices.text = textpos.price
//        Glide.with(context)
//                .load(textpos.resId).into(holder.imageIcon)
//        holder.layout.setOnClickListener {
//            context.startActivity(Intent(context,ShopDetailsActivity().javaClass))
//        }
    }

    class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val num: TextView = itemView.findViewById(R.id.tv_goods_num)
        val price: TextView = itemView.findViewById(R.id.tv_goods_price)
        val name: TextView = itemView.findViewById(R.id.tv_goods_name)
    }
}